package com.itheima;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.Month;

public class LocalDatetimeDemo05 {
    public static void main(String[] args) {
        // 获取当前时间
        LocalDateTime localDateTime = LocalDateTime.now();
        // 当前日期是本年第几天
        // 320
        int dayOfYear = localDateTime.getDayOfYear();
        // 当前日期是本月第几天
        // 16
        int dayOfMonth = localDateTime.getDayOfMonth();
        // 当前日期是本月第几周
        // THURSDAY
        DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
        System.out.println("今天是：" + localDateTime + "\n " +
                "本年中第：" + dayOfYear + "天" + "\n " +
                "本月中第：" + dayOfMonth + "天" + "\n " +
                "本周中星期：" + dayOfWeek.getValue() + "即：" + dayOfWeek + "\n ");

        //    从localdatetime对象获取年月日时分秒信息
        int year = localDateTime.getYear();
        // 2023
        System.out.println("今天年份是：" + year);
        // NOVEMBER
        Month month = localDateTime.getMonth();
        System.out.println("今年月份是：" + month.getValue() + "\n"
                + "即：" + month);
        int hour = localDateTime.getHour();
        System.out.println("当前时间是：" + hour);
        int minute = localDateTime.getMinute();
        System.out.println("当前分钟是：" + minute);
        int second = localDateTime.getSecond();
        System.out.println("当前秒钟是：" + second);

    }
}
